Do not use ORDER BY if the query has a DISTINCT or GROUP BY on the same set of terms, because they have the side effect of ordering rows

http://archives.postgresql.org/pgsql-general/2004-12/msg01340.php